/*!
 * Ajax Extension
 * Author: brown
 */
jQuery.each(["ajax"], function( i, method ) {
	var func = jQuery[method];
	jQuery[method] = function(url, options){
		// If url is an object, simulate pre-1.5 signature
		if ( typeof url === "object" ) {
			options = url;
			url = undefined;
		}
		
		var job = func(url, options);
		job.done(function(response){
			if (response && response.success != undefined) {
				if (!response.success && response.result == 3) {
					//TODO handle error message
					alert(response.message);
					window.top.location.href='/';
				}
			}
		});
		
		return job;
	};
});